// Copyright © SixtyFPS GmbH <info@slint-ui.com>
// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-commercial

import { StyleMetrics } from "std-widgets.slint";

SubElement := Rectangle {
    property sub_color <=> sub.color;
    sub := Text { text: "sub"; }
}

TestCase := Rectangle {
    // This binding allow the test to set the style's default color so that we can compare it
    property<color> binding_to_default_text_color <=> StyleMetrics.default-text-color;

    default_text := Text { text: "default"; }
    text_with_color := Text {
        text: "yellow";
        color: #ffff00ff;
    }
    text_in_sub_element := SubElement { sub_color: #ff0000; }
    text_in_state := Text { }
    states [ xx when false: { text_in_state.color: #abc; } ]

    property <color> default_text_color: default_text.color;
    property <color> color_of_initialized_text: text_with_color.color;
    property <color> color_of_sub_element_text: text_in_sub_element.sub_color;
    property <color> color_in_state: text-in-state.color;

    property <bool> test: default_text_color == StyleMetrics.default-text-color && color-of-initialized-text == #ffff00ff
        && color_of_sub_element_text == #ff0000 && color-in-state == StyleMetrics.default-text-color;
}


/*

```cpp
auto handle = TestCase::create();
const TestCase &instance = *handle;
instance.set_binding_to_default_text_color(slint::Color::from_rgb_uint8(0, 0, 255));
assert_eq(instance.get_default_text_color(), slint::Color::from_rgb_uint8(0, 0, 255));
assert_eq(instance.get_color_of_initialized_text(), slint::Color::from_rgb_uint8(255, 255, 0));
assert_eq(instance.get_color_of_sub_element_text(), slint::Color::from_rgb_uint8(255, 0, 0));
assert_eq(instance.get_color_in_state(), slint::Color::from_rgb_uint8(0, 0, 255));

```

```rust
let instance = TestCase::new().unwrap();
instance.set_binding_to_default_text_color(slint::Color::from_rgb_u8(0, 0, 133));
assert_eq!(instance.get_default_text_color(), slint::Color::from_rgb_u8(0, 0, 133));
assert_eq!(instance.get_color_of_initialized_text(), slint::Color::from_rgb_u8(255, 255, 0));
assert_eq!(instance.get_color_of_sub_element_text(), slint::Color::from_rgb_u8(255, 0, 0));
assert_eq!(instance.get_color_in_state(), slint::Color::from_rgb_u8(0, 0, 133));
```

*/
